<template>
	<view>
		<template v-if="setting.categoryType == 1">
			<shopAreaList @toSearch="getSearchList" ref="list">
				<u-loadmore :status="status" />
			</shopAreaList>
		</template>
		<template v-else-if="setting.categoryType == 2">
			<unusedList @toSearch="getSearchList" ref="list">
				<u-loadmore :status="status" />
			</unusedList>
		</template>
		<template v-else-if="setting.categoryType == 3">
			<merchantServiceList @toSearch="getSearchList" ref="list">
			</merchantServiceList>
				<u-loadmore :status="status" />
		</template>
		<template v-else-if="setting.categoryType == 4 || setting.categoryType == 11 ">
			<supplyChainList @toSearch="getSearchList" ref="list" :typeOn="setting.categoryType == 4? 0 : 1">
				<u-loadmore :status="status" />
			</supplyChainList>
		</template>
		<template v-else-if="setting.categoryType == 5 || setting.categoryType == 10 ">
			<job @toSearch="getSearchList" ref="list" :categoryOn="setting.categoryType == 5? 1 : 0">
				<u-loadmore :status="status" />
			</job>
		</template>
		<template v-else-if="setting.categoryType == 12">
			<projectList  @toSearch="getSearchList" ref="list">
				<u-loadmore :status="status" />
			</projectList>
		</template>
		<template v-else-if="setting.categoryType == 13">
			<brandList  @toSearch="getSearchList" ref="list">
				<u-loadmore :status="status" />
			</brandList>
		</template>
	</view>
</template>

<script>
	import {
		searchData
	} from '@/api/subletOfShop.js'
	import shopAreaList from '../components/searchList/shopAreaList.vue'
	import unusedList from '../components/searchList/unusedList.vue'
	import projectList from '../components/searchList/projectsList.vue'
	import supplyChainList from '../components/searchList/supplyChainList.vue'
	import job from '../components/searchList/job.vue'
	import merchantServiceList from '../components/searchList/merchantServiceList.vue'
	import brandList from '../components/searchList/brandList.vue'
	export default {
		name: 'searchList',
		components: {
			shopAreaList,
			unusedList,
			merchantServiceList,
			supplyChainList,
			job,
			projectList,
			brandList
		},
		props: {
			setting: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				searchList: [],
				status: 'nomore'
			}
		},
		methods: {
			toSearch(params) {
				this.$nextTick(() => {
					console.log("this.$refs.list", this.$refs)
					this.$refs.list?.toSearch(params)
				})
			},
			async getSearchList(params) {
				try {
					params.type = this.setting.categoryType;
					console.log("type", params)
					this.status = 'loading';
					let res = await searchData(params);
					console.log("data", res)
					this.$nextTick(() => {
						console.log(this.$refs.list.list)
						this.$refs.list.list = [...this.$refs.list.list, ...res.data.list]
						this.status = 'nomore';
					})
				} catch (e) {
					this.status = 'nomore';
				}

			}
		}
	}
</script>

<style scoped>
</style>